<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Aria: ArSoundPlayer Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Aria
   &#160;<span id="projectnumber">2.9.4</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classArSoundPlayer.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pro-static-attribs">Static Protected Attributes</a> &#124;
<a href="classArSoundPlayer-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">ArSoundPlayer Class Reference<div class="ingroups"><a class="el" href="group__UtilityClasses.html">Utility Classes</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>This class provides a cross-platform interface for playing short sound samples.  
 <a href="classArSoundPlayer.html#details">More...</a></p>

<p><code>#include &lt;ArSoundPlayer.h&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a814d7e32962633f99ae5229c69502647"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a814d7e32962633f99ae5229c69502647"></a>
static <a class="el" href="classArRetFunctor2.html">ArRetFunctor2</a>&lt; bool, const char *, const char * &gt; *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a814d7e32962633f99ae5229c69502647">getPlayWavFileCallback</a> ()</td></tr>
<tr class="memdesc:a814d7e32962633f99ae5229c69502647"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the static functor for playWavFile. <br /></td></tr>
<tr class="separator:a814d7e32962633f99ae5229c69502647"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ace0317817d565d9328500bbe806eefac"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classArFunctor.html">ArFunctor</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#ace0317817d565d9328500bbe806eefac">getStopPlayingCallback</a> ()</td></tr>
<tr class="memdesc:ace0317817d565d9328500bbe806eefac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the static functor for <a class="el" href="classArSoundPlayer.html#a1dfdc61208ea4fe3289f29e4df1bd31d" title="Cancel (interrupt) any current sound or file playback. ">stopPlaying()</a>.  <a href="#ace0317817d565d9328500bbe806eefac">More...</a><br /></td></tr>
<tr class="separator:ace0317817d565d9328500bbe806eefac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad1f41bd5dceea84a793b33cf14f3d126"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#ad1f41bd5dceea84a793b33cf14f3d126">playNativeFile</a> (const char *filename, const char *params)</td></tr>
<tr class="memdesc:ad1f41bd5dceea84a793b33cf14f3d126"><td class="mdescLeft">&#160;</td><td class="mdescRight">Play a file in some native file format for the compilation platform.  <a href="#ad1f41bd5dceea84a793b33cf14f3d126">More...</a><br /></td></tr>
<tr class="separator:ad1f41bd5dceea84a793b33cf14f3d126"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a45bd8e1fd1abf13e1e4e2d00339621f4"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a45bd8e1fd1abf13e1e4e2d00339621f4">playSoundPCM16</a> (char *data, int numSamples)</td></tr>
<tr class="memdesc:a45bd8e1fd1abf13e1e4e2d00339621f4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Play raw uncompressed PCM16 sound data.  <a href="#a45bd8e1fd1abf13e1e4e2d00339621f4">More...</a><br /></td></tr>
<tr class="separator:a45bd8e1fd1abf13e1e4e2d00339621f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a023a076feeaa5da3d7c69681f6661d60"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a023a076feeaa5da3d7c69681f6661d60">playWavFile</a> (const char *filename, const char *params)</td></tr>
<tr class="memdesc:a023a076feeaa5da3d7c69681f6661d60"><td class="mdescLeft">&#160;</td><td class="mdescRight">Play a WAV (Windows RIFF) file.  <a href="#a023a076feeaa5da3d7c69681f6661d60">More...</a><br /></td></tr>
<tr class="separator:a023a076feeaa5da3d7c69681f6661d60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af67e776021660556feffe660ed639367"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af67e776021660556feffe660ed639367"></a>
static bool&#160;</td><td class="memItemRight" valign="bottom"><b>playWavFile</b> (const char *filename)</td></tr>
<tr class="separator:af67e776021660556feffe660ed639367"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bf45927aff8358d30fcc48de6683ede"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a7bf45927aff8358d30fcc48de6683ede">setVolume</a> (double v)</td></tr>
<tr class="memdesc:a7bf45927aff8358d30fcc48de6683ede"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set a volume adjustment applied to all sounds right before playing.  <a href="#a7bf45927aff8358d30fcc48de6683ede">More...</a><br /></td></tr>
<tr class="separator:a7bf45927aff8358d30fcc48de6683ede"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7af22400dc046250534ca2ba6712621f"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a7af22400dc046250534ca2ba6712621f">setVolumePercent</a> (double pct)</td></tr>
<tr class="memdesc:a7af22400dc046250534ca2ba6712621f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set volume as a "percent" of normal, where 100% is normal or natural volume, 50% is increased by 50%, -50% is decreased by 50%, etc.  <a href="#a7af22400dc046250534ca2ba6712621f">More...</a><br /></td></tr>
<tr class="separator:a7af22400dc046250534ca2ba6712621f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1dfdc61208ea4fe3289f29e4df1bd31d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a1dfdc61208ea4fe3289f29e4df1bd31d">stopPlaying</a> ()</td></tr>
<tr class="memdesc:a1dfdc61208ea4fe3289f29e4df1bd31d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Cancel (interrupt) any current sound or file playback.  <a href="#a1dfdc61208ea4fe3289f29e4df1bd31d">More...</a><br /></td></tr>
<tr class="separator:a1dfdc61208ea4fe3289f29e4df1bd31d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-static-attribs"></a>
Static Protected Attributes</h2></td></tr>
<tr class="memitem:a1148de5352a279d6d56878a1a9196b44"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1148de5352a279d6d56878a1a9196b44"></a>
static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classArSoundPlayer.html#a1148de5352a279d6d56878a1a9196b44">ourPlayChildPID</a> = -1</td></tr>
<tr class="memdesc:a1148de5352a279d6d56878a1a9196b44"><td class="mdescLeft">&#160;</td><td class="mdescRight">Only used on Linux. <br /></td></tr>
<tr class="separator:a1148de5352a279d6d56878a1a9196b44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1733bcb76f6eb38cf25f8060aa94edf"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa1733bcb76f6eb38cf25f8060aa94edf"></a>
static <a class="el" href="classArGlobalRetFunctor2.html">ArGlobalRetFunctor2</a>&lt; bool, const char *, const char * &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>ourPlayWavFileCB</b></td></tr>
<tr class="separator:aa1733bcb76f6eb38cf25f8060aa94edf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adcb3b7ed73965b34a861260886536236"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adcb3b7ed73965b34a861260886536236"></a>
static <a class="el" href="classArGlobalFunctor.html">ArGlobalFunctor</a>&#160;</td><td class="memItemRight" valign="bottom"><b>ourStopPlayingCB</b></td></tr>
<tr class="separator:adcb3b7ed73965b34a861260886536236"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac6cb7b64e0aac80c9703ff522d7497d0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac6cb7b64e0aac80c9703ff522d7497d0"></a>
static double&#160;</td><td class="memItemRight" valign="bottom"><b>ourVolume</b> = 1.0</td></tr>
<tr class="separator:ac6cb7b64e0aac80c9703ff522d7497d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This class provides a cross-platform interface for playing short sound samples. </p>
<p>(Currently implemented for Windows and Linux). </p><dl class="section see"><dt>See also</dt><dd>For I/O and network transfer of encoded audio, see the ArNetAudio library. </dd>
<dd>
<a class="el" href="classArSoundsQueue.html" title="This class manages a queue of items to play as WAV files or as text to speak using a speech synthesiz...">ArSoundsQueue</a></dd></dl>
<dl class="section note"><dt>Note</dt><dd>Uses an external program to play WAV files on Linux. If an environment variable named PLAY_WAV is set, that program is used, otherwise, 'play' from the 'sox' toolset is used. PLAY_WAV must contain one word (the command; no arguments) A call to <a class="el" href="classArSoundPlayer.html#a023a076feeaa5da3d7c69681f6661d60" title="Play a WAV (Windows RIFF) file. ">playWavFile()</a> will return immediately after 'play' has finished, even though Linux may still be playing back the sound data. In general, this kind of thing is a problem, especially with speech recognition immediately after playing a sound. Ideally, we should be able to truly block until the sound has finished playback. Alas, it is not an ideal world. Another potential pitfall due to the use of an external program invocation: the program you call must not attempt to issue any output. 'play' from the 'sox' toolset automatically supresses normal output if it isn't called from an interactive terminal, but it may still issue some error messages, which will cause it to hang indefinately.</dd></dl>
<p>The volume (level) of audio output from a robot is determined by two things: the computer sound device mixer, and also the amplifier which drives the speakers. The computer's mixer can be adjusted through the operating system: on Linux, you can use the 'aumix' program to adjust the Master and PCM levels. On Windows, use the Windows mixer program. If on Linux, <a class="el" href="classArSoundPlayer.html" title="This class provides a cross-platform interface for playing short sound samples. ">ArSoundPlayer</a> also prodives the <a class="el" href="classArSoundPlayer.html#a7bf45927aff8358d30fcc48de6683ede" title="Set a volume adjustment applied to all sounds right before playing. ">setVolume()</a> method, which adjusts the volume of the sound before it is played. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="ace0317817d565d9328500bbe806eefac"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classArFunctor.html">ArFunctor</a> * ArSoundPlayer::getStopPlayingCallback </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the static functor for <a class="el" href="classArSoundPlayer.html#a1dfdc61208ea4fe3289f29e4df1bd31d" title="Cancel (interrupt) any current sound or file playback. ">stopPlaying()</a>. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="soundsQueueExample_8cpp-example.html#a5">soundsQueueExample.cpp</a>.</dd>
</dl>
</div>
</div>
<a class="anchor" id="ad1f41bd5dceea84a793b33cf14f3d126"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool ArSoundPlayer::playNativeFile </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Play a file in some native file format for the compilation platform. </p>

</div>
</div>
<a class="anchor" id="a45bd8e1fd1abf13e1e4e2d00339621f4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool ArSoundPlayer::playSoundPCM16 </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSamples</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Play raw uncompressed PCM16 sound data. </p>
<p>The format of this data is numSamples samples of two bytes each. Each byte pair is a signed little endian integer. The sound will be played back at 16kHz, monaurally. </p><dl class="section return"><dt>Returns</dt><dd>false on error, true on success. </dd></dl>

</div>
</div>
<a class="anchor" id="a023a076feeaa5da3d7c69681f6661d60"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool ArSoundPlayer::playWavFile </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Play a WAV (Windows RIFF) file. </p>
<dl class="section note"><dt>Note</dt><dd>Uses an external program to play WAV files on Linux. If an environment variable named PLAY_WAV is set, that program is used, otherwise, 'play' from the 'sox' toolset is used. See detailed note in the overview for this cass. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">filename</td><td>Name of the file to play </td></tr>
    <tr><td class="paramname">params</td><td>ignored </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a7bf45927aff8358d30fcc48de6683ede"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ArSoundPlayer::setVolume </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>v</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set a volume adjustment applied to all sounds right before playing. </p>
<p>(So this adjusts the volume in addition to, not instead of, the computer audio mixer). Any value less than or equal to 0 is no volume i.e. muted or no output. </p><dl class="section note"><dt>Note</dt><dd>Available on Linux only </dd></dl>

</div>
</div>
<a class="anchor" id="a7af22400dc046250534ca2ba6712621f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ArSoundPlayer::setVolumePercent </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>pct</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set volume as a "percent" of normal, where 100% is normal or natural volume, 50% is increased by 50%, -50% is decreased by 50%, etc. </p>
<p>(-100.0% is no volume, or mute.) </p><dl class="section note"><dt>Note</dt><dd>Available on Linux only </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="soundsQueueExample_8cpp-example.html#a27">soundsQueueExample.cpp</a>.</dd>
</dl>
</div>
</div>
<a class="anchor" id="a1dfdc61208ea4fe3289f29e4df1bd31d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ArSoundPlayer::stopPlaying </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Cancel (interrupt) any current sound or file playback. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>ArSoundPlayer.h</li>
<li>ArSoundPlayer.cpp</li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="classArSoundPlayer.html">ArSoundPlayer</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
